<?php
	$arrParam 	= $this->arrParam;
	
	$arrFilter 	= $arrParam['arrFilter'];
	
	$statusOption = 	array(
								'none'=>'-- ' . $this->translate('Status') . ' --',
						  		'active'=>$this->translate('Actice'),
						  		'inactive'=>$this->translate('Inactive'),
						 	);
	$classStatus 	= (empty($arrFilter['status']) || $arrFilter['status'] == 'none')? 'width-150': 'width-150 bg-green2';						 
	$slbStatus 		= $this->formSelect('status',$arrFilter['status'],array('class'=>$classStatus),$statusOption);
	
	$classGroup = (empty($arrFilter['group_id']) || $arrFilter['group_id'] == 'none')? 'width-150': 'width-150 bg-green2';
	$slbGroup	= $this->cmsSelect('group_id', $arrFilter['group_id'], array('class' => $classGroup), $this->sblGroup);
	
	$lnkFiter 	= $this->url(array('action'=>'filter','type'=>'filter'));
	$btnFiter 	= $this->formButton('submit-filter',$this->translate("Filter"),
								array('class'=>'button','onclick'=>"onSubmitForm('appForm','" . $lnkFiter . "')"));
	
	$strFilter 	= $slbGroup . ' ' . $slbStatus . ' ' . $btnFiter;
	
	$classKeyword = (empty($arrFilter['keyword']))? 'width-150': 'width-150 bg-green2';
	$keyword 	= $this->formText('keyword',$arrFilter['keyword'],array('class'=>$classKeyword));
	
	$slbFiels	= $this->formSelect('search-field',$arrFilter['searchField'],array('class'=>'width-150'),$this->slbSearchFiels);
	
	$lnkGo 		= $this->url(array('action'=>'filter','type'=>'search'));
	$btnGo 		= $this->formButton('search',$this->translate("Search"),
								array('onclick'=>"onSubmitForm('appForm','" . $lnkGo . "')",'class'=>'button'));
								
	$lnkClear 	= $this->url(array('action'=>'filter','type'=>'clear'));
	$btnClear 	= $this->formButton('clear',$this->translate("Clear"),
								array('onclick'=>"onSubmitForm('appForm','" . $lnkClear . "')",'class'=>'button'));
								
	$strSearch = '<b>' . $this->translate('Keywords') . ':</b> ' 
				 . $keyword . ' ' . $slbFiels . ' ' . $btnGo . ' ' . $btnClear;

?>

<?php echo $this->render($this->includeDir . '/toolbar.php');?>
<?php echo $this->flashMessage();?>
<div id="element-box">
            <div class="m">
            	<div class="filter-result">
            		<div style="float: left;">
            			 <?php echo $strSearch;?>
	                </div>
	                <div style="float: right;">
            			<?php echo $strFilter;?>
            		</div>
            		<div class="clr"></div>
            	</div>
            	
                <div class="div-table">
                <table width="100%" border="0" class="adminlist">
                <thead>
                	 <?php 
                	 	$lblStatus 			= $this->cmsSort($this->translate('Status'),$arrFilter,'u.status','DESC');
                	 	$lblEmail 			= $this->cmsSort($this->translate('Email'),$arrFilter,'u.email','DESC');
                	 	$lblName 			= $this->cmsSort($this->translate('Name'),$arrFilter,'u.first_name','DESC');
                	 	$lblRegisterDate	= $this->cmsSort($this->translate('Register date'),$arrFilter,'u.created','DESC');
                	 	$lblGroupDefault	= $this->cmsSort($this->translate('Group default'),$arrFilter,'group_name','DESC');
                	 	$lblControl			= $this->translate('Control');
                	 	$lblID 				= $this->cmsSort($this->translate('ID'),$arrFilter,'u.id','DESC');
                	 	require 'includes/row-thead.php';
                	 ?>
                 </thead>
                 <tbody>
                 <?php 
                 	$empty 			= '<em style="color:#ccc">updating...</em>';
                 	if(count($this->Items)> 0){
                 		$i = 1;
                 		foreach ($this->Items as $key => $val){
                 			$cssTR = 'odd';
                 			if($i%2==0) $cssTR = 'even';
                 			$cid = $this->formCheckbox('cid[]',$val['id']);
                 			$attribs = array('icon'=>'inactive.png','iconDir' => "images/small-icons/");
							if($val['status'] == 'active')$attribs['icon'] = 'active.png';
							$lnkStatus  	= $this->url(array('action'=>'status','id'=> $val['id'],'s'=>$val['status']));
							$status 		= $this->cmsIcon('Status',$lnkStatus,$attribs);
							$j = 0;
							$email			= $val['email'];
							$register_date 	= $val['created'];
							$group_default 	= $val['group_name'];
							
							$name 			= $val['first_name'];
							if($name != '') $name .= ' ';
							$name 			.= $val['last_name'];
							$control = '---';
							$iconDel = '';
							
							if($val['group_default'] != 1){
								$lnkDel  = $this->url(array('action'=>'delete','id'=> $val['id']));
								$options = array('type'=>'submit','name'=>'appForm',
												 'notice'=>$this->translate('Are you sure you want to delete this item?'));
								$iconDel = $this->cmsIcon('Delete item',$lnkDel,array('icon'=>'icon-delete.png'),$options);
							}
							
							$lnkInfo  	= $this->url(array('action'=>'info','id'=> $val['id']));
							$iconInfo 	= $this->cmsIcon('View Info',$lnkInfo,array('icon'=>'icon-info.png'));
												
							$lnkEdit  	= $this->url(array('action'=>'edit','id'=> $val['id']));
							$iconEdit 	= $this->cmsIcon('Edit item',$lnkEdit,array('icon'=>'icon-edit.png'));
												
							$control 	= $iconInfo . ' ' . $iconEdit . ' ' . $iconDel;
												
							$id = $val['id'];
                    		
                			require 'includes/row-tbody.php';
                			$i++;
                 		}
                 	}else{
                 		echo $this->render('empty.php');
                 	}
                  ?>
                  </tbody>
                  <tfoot>
                      <tr>
                        <td colspan="15">
                        	<?php echo $this->paginationControl($this->panigator,'Sliding','paning.php',array('arrParam'=>$arrParam));?>
                        </td>
                      </tr>
                  </tfoot>
                </table>

                </div>
            </div>
         </div>